<template>
	<view class="rzBox">
		<view class="top">
			
		</view>
		<view class="content">
			<view class="tablist ">
				<view @click="goRz(1)">用户认证 </view>
				<view @click="goRz(2)">服务商认证 </view>
				<view @click="goRz(3)">专家认证 </view>
			</view>
			<!-- <view class="tablist flex-row flex-between">
				<view @click="shiming()">实名认证 </view>
			</view> -->
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				userinfo:{}
			}
		},
		mounted() {
			this.getInfo()
		},
		
		methods:{
			getInfo(){
				let id = uni.getStorageSync('userId')
				this.$http.get('/userCenter/getUserInfoById', {id:id}).then(res => {
					if (res.code == '0') {
						console.log(res.data)
						uni.setStorageSync('certificationStatus', res.data.certificationStatus);
						this.userinfo = res.data
					}else{
						uni.showToast({
							icon:"none",
							title:res.msg
						})
					}
				})
			},
			shiming(){
				if(this.userinfo.idCard){
					if(!this.userinfo.isRealName){
						uni.navigateTo({
							url:`/pages/person/userAuth`
						})
					}else{
						uni.showToast({
							icon:"none",
							title:"你已实名认证，无需再次操作！"
						})
					}
				}else{
					uni.showToast({
						icon:"none",
						title:"请先完善个人身份资料！"
					})
				}
				
			},
			goRz(index){
				let rzStatus = uni.getStorageSync('certificationStatus')
				// 认证状态 1 = 未认证，2=用户认证，3=服务商认证，4=认证中
				if(rzStatus==1){
					if(index==1){
						uni.navigateTo({
							url:'/pages/person/sendrz'
						})
					}else if(index==2){
						uni.showToast({
							icon:"none",
							title:"请先用户认证"
						})
					}else if(index==3){
						uni.showToast({
							icon:"none",
							title:"请先用户认证"
						})
					}
				}else if(rzStatus == 2 || rzStatus == 3){
					if(index==1){
						uni.showToast({
							icon:"none",
							title:"您已认证成功"
						})
					}else if(index==2){
						if(rzStatus == 3){
							uni.showToast({
								icon:"none",
								title:"您已认证成功"
							})
						}else if(rzStatus == 2){
							uni.navigateTo({
									url:'/pages/person/sendrzfws'
							})
						}
				      
					}else if(index==3 ){
						if(this.userinfo.userType!==2){
							uni.navigateTo({
								url:'./sendProfess'
							})
						}else if(this.userinfo.userType==2){
							uni.showToast({
								icon:"none",
								title:"您已认证成功"
							})
						}
					}
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.rzBox{
		.top{
			height: 360upx;
			background: url(../../static/icon/rz_bg.png) no-repeat left top;
			background-size: 100% 100%;
		}
		.content{
			.tablist{
				padding: 30upx;
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;
				>view{
					width:45%;
					height:148upx;
					background:url(../../static/icon/rz_btn_bg@2x.png) no-repeat left top;
					background-size: 100% 100%;
					border-radius:20upx;
					font-size: 32upx;
					color: #37190A;
					line-height: 148upx;
					text-align: center;
					margin-bottom: 40upx;
				}
			}
		}
	}
</style>
